Update evm_consumer functions implemented#2
Update evm_consumer functions implemented#2XiangEnze wants to merge 29 commits intobase/consumer-chain-supportfrom
Conversation
clientcontroller/evm_consumer.go
Outdated
| Hash string | ||
| } | ||
|
|
||
| var Batch []rpc.BatchElem |
There was a problem hiding this comment.
same here Batch should be batch
clientcontroller/evm_consumer.go
Outdated
|
|
||
| var Batch []rpc.BatchElem | ||
|
|
||
| InitBatch(Batch, startnumber, count, "ascent") |
There was a problem hiding this comment.
InitBatch -> initBatch
if you check other function in the file, first-letter-capitalization is only for interface function.
clientcontroller/evm_consumer.go
Outdated
| return nil, fmt.Errorf("error:%s", err) | ||
| } | ||
|
|
||
| ibatch := &types.BlockInfo{ |
There was a problem hiding this comment.
what does ibatch mean? it's a block not a batch.
clientcontroller/evm_consumer.go
Outdated
|
|
||
| for _, batch := range batchArray { | ||
| nb := batch.Result.(*Block) | ||
| num, err := strconv.ParseUint(strings.TrimPrefix(nb.Number, "0x"), 16, 64) |
There was a problem hiding this comment.
this looks very wrong. query a block should be very simply and standard operation
the entire implementation of this function should be concise
|
discussed w @XiangEnze and @lesterli offline. a few things:
references: |
clientcontroller/evm_consumer.go
Outdated
|
|
||
| var blocks []*types.BlockInfo | ||
|
|
||
| /*will be implemented in next PR, wait for "refactor: QueryLatestFinalizedBlocks(count uint64) -> QueryLatestFinalizedBlock() #347" |
There was a problem hiding this comment.
ok it's already merged now. see the msg in TG group and update accordingly
you also need to sync changes from upstream and change base branch
clientcontroller/evm_consumer.go
Outdated
| func (ec *EVMConsumerController) queryLatestBlocks(startKey []byte, count uint64, status finalitytypes.QueriedBlockStatus, reverse bool) ([]*types.BlockInfo, error) { | ||
| var blocks []*types.BlockInfo | ||
|
|
||
| // Can be deleted for never using |
There was a problem hiding this comment.
if it's easy to do, you can just remove it here
Makefile
Outdated
|
|
||
| .PHONY: test | ||
| test: | ||
| make mock-gen |
finality-provider/config/evm.go
Outdated
| RPCL1Addr string `long:"rpc-address" description:"address of the L2 RPC server to connect to"` | ||
| RPCL2Addr string `long:"rpc-address" description:"address of the L1 RPC server to connect to"` |
There was a problem hiding this comment.
"RPCL1Addr - address of the L2 RPC"
finality-provider/config/evm.go
Outdated
| RPCAddr string `long:"rpc-address" description:"address of the rpc server to connect to"` | ||
| RPCL1Addr string `long:"rpc-address" description:"address of the L2 RPC server to connect to"` | ||
| RPCL2Addr string `long:"rpc-address" description:"address of the L1 RPC server to connect to"` | ||
| L2OutputOracleContractAddress string `long:"sol-address" description:"address of the L2output smart contract"` |
finality-provider/config/evm.go
Outdated
| RPCL1Addr string `long:"rpc-address" description:"address of the L2 RPC server to connect to"` | ||
| RPCL2Addr string `long:"rpc-address" description:"address of the L1 RPC server to connect to"` | ||
| L2OutputOracleContractAddress string `long:"sol-address" description:"address of the L2output smart contract"` | ||
| BitcoinStackingContractAddress string `long:"sol-address" description:"address of the Bitcoinstaking smart contract"` |
There was a problem hiding this comment.
why this is also called long:"sol-address"? sounds wrong
what does "long" mean here?
Summary
Updated EVMConfig for necessary addresses for evm_consumer, add some functions to avoid duplicates or large functions.
Import
op-bindings:so we can interact with the L1 contract like the L2OutputOracle
Replaced
evmclientwithl1Clientandl2Client, so we can reuse both to get information L1 and L2.Using
ethclientinstead ofrpc.clientmade functions much more lightweight.Deleted useless functions.
Note that loading full blocks by
BlockByNumberrequires two requests, so useHeaderByNumberif we don't need all transactions or uncle headers.Updated
sdk "github.com/cosmos/cosmos-sdk/types"not used any more, already deletedqueryLatestBlocks()is not used any more, already deletedQueryLatestFinalizedBlocks()Next Steps:
QueryActivatedHeightTest Plan